#include <iostream>
#include <map>
#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/shared_mutex.hpp>

struct user_info {
	std::string address;
	unsigned short age;
};

class users_online {
	typedef boost::shared_mutex mutex_t;
	mutable mutex_t users_mutex_;
	std::map<std::string, user_info> users_;

public:
	bool is_online(const std::string& username) const {
		boost::shared_lock<mutex_t> lock(users_mutex_);
		return users_.find(username) != users_.end();
	}

	unsigned short get_age(const std::string& username) const {
		boost::shared_lock<mutex_t> lock(users_mutex_);
		return users_.at(username).age;
	}

	void set_online(const std::string& username, const user_info& data)
	{
		std::lock_guard<mutex_t> lock(users_mutex_);
		users_.insert(std::make_pair(username, data));
	}
};

int main()
{

}